package com.ljc.api;

import com.ljc.interfaces.UserCoinApi;
import com.ljc.mapper.UserCoinMapper;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;
import java.util.Date;

@DubboService
public class UserCoinApiImpl implements UserCoinApi {
    @Resource
    private UserCoinMapper userCoinMapper;

    /**
     * 根据用户id查询用户拥有的硬币数
     */
    @Override
    public Integer getUserCoinsAmount(Long userId) {
        return userCoinMapper.getUserCoinsAmount(userId);
    }

    /**
     * 更新用户当前硬币总数
     */
    @Override
    public void updateUserCoinsAmount(Long userId, int amount) {
        userCoinMapper.updateUserCoinAmount(userId, amount, new Date());
    }
}
